﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Events.Chapter2
{
    class Program
    {
        static void Main(string[] args)
        {
            var worker = new Worker();
            worker.WorkPerfomed += worker_WorkPerfomed;
            worker.WorkCompleted += worker_WorkCompleted;

            //anonymus function
            worker.WorkPerfomed += delegate(object sender, WorkPerformentEventArgs e) 
                {
                    Console.WriteLine(e.Hours);
                };

            //lambda
            worker.WorkPerfomed += (s, e) => Console.WriteLine("lambda worked");

            worker.DoWork(5, WorkType.GoToMeetings);

            Console.ReadLine();
        }

        static void worker_WorkCompleted(object sender, EventArgs e)
        {
            Console.WriteLine("Work Completed");
        }

        static void worker_WorkPerfomed(object sender, WorkPerformentEventArgs e)
        {
            Console.WriteLine("the hours: " + e.Hours + " and work type: " + e.WorkType);
        }
    }
}
